#ifndef SKILLWIDGET_H
#define SKILLWIDGET_H

#include"ui_skill.h"
#include<QValidator>
#include<QMap>

#include "serialize/skill.h"
#include "serialize/equipment.h"
#include "serialize/general.h"

namespace Ui{
class SkillWidget;
}

class SkillWidget : public QWidget
{
    Q_OBJECT

public:
    explicit SkillWidget(QWidget* p=0);
    ~SkillWidget();

    inline void setFilePath(QString s){filePath = s;}
    inline void setWorkPath(QString s){workPath = s;}
    void initialMap();
    Skill getSkillFromUI();
    void displaySkillToUI(Skill& m);
    Skill readSkillFromFile();
    bool saveSkillToFile();
    void clearUI();

    static void exportToBinary(QString workspacepath);
    static void exportToXML(QString workspacepath);
    static bool importFromXML(QString workspacepath,QString xmlFile);

    void addTreeItems(QList<QTreeWidgetItem*> items);

    Ui::SkillWidget* ui;

public slots:
    void s_skillConditionItemDoubleClicked(QTreeWidgetItem* item,int col);
    void s_cellDoubleClicked(int row, int column);

private:
    QString filePath;
    QString workPath;
    QMap<int,QString> equipMap;
    QMap<int,QString> generalMap;
    void setInputMask();
};

#endif // SKILLWIDGET_H
